<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <canvas id="canvas" style="border: 1px solid #aaa; display: block; margin: 50px auto;">
        当前浏览器不支持Canvas，请更换浏览器
    </canvas>
    <script>
        window.onload = function () {
            var canvas = document.getElementById("canvas");

            canvas.width = 800;
            canvas.height = 800;

            var context = canvas.getContext("2d");

            var radialGrad = context.createRadialGradient(400, 400, 100, 400, 400, 500);

            radialGrad.addColorStop(0.0, 'white');
            radialGrad.addColorStop(0.25, 'yellow');    //25%的位置黄色
            radialGrad.addColorStop(0.5, 'green');
            radialGrad.addColorStop(0.75, 'blue');
            radialGrad.addColorStop(1.0, 'black');

            context.fillStyle = radialGrad;
            context.fillRect(0, 0, 800, 800);
        }
    </script>
</body>
</html>